package com.example.security.controller;

import com.example.security.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author linzp
 * @date 2022/2/10 15:38
 */
@RestController
@RequestMapping("/system")
public class UserController {

    @Autowired
    private UserDetailsService userDetailsService;

    /**
     * 获取用户.
     *
     * @return
     */
    @GetMapping("/user")
    public Result<UserDetails> getUser(@RequestParam("username") String username) {
        return Result.success(userDetailsService.loadUserByUsername(username));
    }

    /**
     * 获取用户.
     *
     * @return
     */
    @GetMapping("/hello")
    public Result<String> sayHello() {
        return Result.success("hello world");
    }
}
